package meijuli.com.join51.business.utils;

import android.app.AppOpsManager;
import android.content.Context;
import android.os.Binder;
import android.os.Build;
import android.support.annotation.RequiresApi;

import com.jhx.common.utils.ToastUtil;

public class FixXiaomiPermissionUtils {

    @RequiresApi(api = Build.VERSION_CODES.M)
    public static Boolean isAppRefusePermission(Context context) {
        AppOpsManager appOpsManager = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
        int checkOp = appOpsManager.checkOp(AppOpsManager.OPSTR_CAMERA, Binder.getCallingUid(), context.getPackageName());
        if (checkOp == AppOpsManager.MODE_IGNORED) {
            // 权限被拒绝了
            ToastUtil.getInstance().showToast("请去权限管理中开启相机权限");
            return true;
        }
        return false;
    }
}